<template>
  <div class="app">
    <h1>我是App组件</h1>
    <p>子组件传递过来的数据:{{ name }}--{{ address }}</p>
    <!--通过自定义事件和props用于子组件给父组件传递数据-->
    <Student @getNameData="getNameData" :getAddressData="getAddressData" ref="student"></Student>
  </div>
</template>
<script>
import Student from "@/components/Student.vue";

export default {
  name: "App",
  components: {Student},
  data() {
    return {name: "", address: ""};
  },
  methods: {
    getNameData(name) {
      this.name = name
    },
    getAddressData(address) {
      this.address = address
    }
  },
  mounted() {
    /*this.$refs.student.sendData()
    this.$refs.student.$on("getNameData",this.getNameData)
    this.$refs.student.$once("getNameData",this.getNameData)
    */
  }
};
</script>
<style lang="less">
.app {
  width: 100%;
  height: 300px;
  background-color: #cccccc;
}
</style>
